package de.suur.jarmi.common;

public class JarmiUtil {

	public static final String JARMI = "JARMI";
	public static final byte[] JARMI_BYTES = JARMI.getBytes();

	public static int byteArrayToInt(byte[] b) {
		return (b[0] << 24) + ((b[1] & 0xFF) << 16) + ((b[2] & 0xFF) << 8)
				+ (b[3] & 0xFF);
	}

	public static byte[] intToByteArray(int value) {
		return new byte[] { (byte) (value >>> 24), (byte) (value >>> 16),
				(byte) (value >>> 8), (byte) value };
	}

	public static String toString(byte[] data) {
		String result = "";
		for (byte b : data) {
			result += Integer.toHexString(b) + " ";
		}
		return result;
	}

}
